package com.hmall.feign.client;

import com.hmall.feign.common.dto.PageDTO;
import com.hmall.feign.common.pojo.Item;
import com.hmall.feign.config.MyConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "itemservice",configuration = MyConfig.class)
public interface ItemFeign {
    /**
     * 分页查询商品
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/item/list")
    PageDTO<Item> list(@RequestParam(name = "page") Integer page,
                       @RequestParam(name = "size") Integer size);

    /**
     * 根据id查询商品
     * @param id
     * @return
     */
    @GetMapping("/item/{id}")
    Item getById(@PathVariable Long id);

    /**
     * 根据id扣减库存
     * @param itemId
     * @param num
     */
    @PutMapping("/item/stock/{itemId}/{num}")
    String updateStock(@PathVariable Long itemId,
                            @PathVariable Integer num );
}
